<html><head>
   <script type="text/javascript" src=
      "http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js">
      </script>
   <script>
      function getIt(){
         var url = "/ws"
         new Ajax.Request(url, {
            method: "get",
            parameters: "id=183399670",
            onSuccess: cbgood,
            onFailure: cbbad
         });
      }

      function postIt(no_params){
         var post_data;
         if(no_params){
            post_data = "oauth_consumer_key=";
            post_data += "http%3a%2f%2fwww.myspace.com%2f452451983"
            post_data += "&oauth_nonce=633709335062612050";
            post_data += "&oauth_signature=HsFBfrkYqfVC1Vbg%2bPoDilQ%2bxwY%3d";
            post_data += "&oauth_signature_method=HMAC-SHA1";
            post_data += "&oauth_timestamp=1235336706";
            post_data += "&oauth_version=1.0";
            post_data += "&opensocial_owner_id=183399670";
            post_data += "&opensocial_viewer_id=183399670";
         }
         else{
            post_data = "oauth_consumer_key=";
            post_data += "http%3a%2f%2fwww.myspace.com%2f452451983"
            post_data += "&oauth_nonce=633709359708656300";
            post_data += "&oauth_signature=xPilVFmP4reCHh6ODD%2bTWEkAflw%3d";
            post_data += "&oauth_signature_method=HMAC-SHA1";
            post_data += "&oauth_timestamp=1235339170";
            post_data += "&oauth_version=1.0";
            post_data += "&opensocial_owner_id=183399670";
            post_data += "&opensocial_viewer_id=183399670";
            post_data += "&a=b";
         }

         //resource url: http://mstari.org/Default.aspx
         // secret: 8d804c4ffe6c4f46bf5c040c3e9c0e21

         var url = "/ws?" + post_data;
         new Ajax.Request(url, {
            method: "post",
            onSuccess: cbgood,
            onFailure: cbbad
         });
      }
	  
	  function getter(action, params){
	  	 var url = "/test";
		 
		 if(params){
		 	var chunks = params.split("&");
			params = "";
			
			for(var i = 0; i < chunks.length; i++){
				var key = chunks[i].split("=")[0];
				var val = chunks[i].split("=")[1];
				
				if(params !== ""){
					params += "&";
				}
				
				params += key + "=";
				
				if(isNaN(parseInt(val)) || val.indexOf(",") >= 0){
					params += "\"" + val + "\"";
				}
				else{
					params += val;
				}
			}
		 }
		 
         new Ajax.Request(url, {
            method: "get",
            parameters: "arg0=183399670&" + params + "&action=" + action,
            onSuccess: cbgood,
            onFailure: cbbad
         });
	  }

      function cbgood(response){
         document.getElementById("output").innerHTML = response.responseText;
      }

      function cbbad(response){
         document.getElementById("output").innerHTML = response;
      }
   </script>
</head>

<body>
   <div id="output"></div>

   <button onclick="getIt()">GET</button>
   <button onclick="postIt(true)">POST No Params</button>
   <button onclick="postIt(false)">POST Params a=b</button>
   <button onclick="getter('Albums')">Albums</button>
   <button onclick="getter('Album', 'arg1=542074')">Album</button>
   <button onclick="getter('Friends')">Friends</button>
   <button onclick="getter('Friendship', 'arg1=6221')">Friendship</button>
   <button onclick="getter('Mood')">Mood</button>
   <button onclick="getter('Moods')">Moods</button>   
   <button onclick="getter('Photos')">Photos</button>
   <button onclick="getter('Photo', 'arg1=1982932')">Photo</button>
   <button onclick="getter('Profile', 'arg1=extended')">Profile</button>
   <button onclick="getter('Status')">Status</button>
   <button onclick="getter('Videos')">Videos</button>
   <button onclick="getter('Video', 'arg1=55701156')">Video</button>
   <button onclick="getter('Activities')">Activities</button>
   <button onclick="getter('ActivitiesFriends')">ActivitiesFriends</button>
   <button onclick="getter('SetStatus', 'arg1=some_new_status')">SetStatus</button>
   <button onclick="getter('SetMood', 'arg1=some_new_mood')">SetMood</button>
   <button onclick="getter('CreateAlbum', 'arg1=album_title&arg2=some_location&arg3=Me')">CreateAlbum</button>
   <button onclick="getter('Indicators')">Indicators</button>
   <button onclick="getter('SendNotification', 'arg1=118991&arg2=183399670,123965750&arg3=some_content&arg4=lbl0&arg5=canvas&arg6=lbl1&arg7=appProfile&arg8=http://api.myspace.com/v1/users/183399670')">SendNotification</button>
</body></html>
